from scipy import interpolate
import numpy as np
from Sector_Parameters import *



Nr,Nt,Nz,dr,dt,dz,Np,NN,Nx,Nw,Ny,Nv,N_p, Nx_aug,sigma_pnts=circular_parameters()
DeltaT, Tsim, Nsim=time_parameters()

Nt_new = 85
Nr_new = 146

def create_interpolate(x,y):
    f_cubic=interpolate.Rbf(x,y,kind='linear')
    #f_cubic=interpolate.Akima1DInterpolator(x,y)
    return f_cubic

def values_interpolate(x_new,x_old,y_old):
    F_cubicCur=create_interpolate(x_old,y_old)
    y_new=F_cubicCur(x_new)
    return y_new

def new_values(Z_old):
    Nt = 17
    x_old = np.arange(0, 300, 10)
    #x_old=np.array([0,10,20,30,40,50])
    x_new=np.linspace(0,290,Nr_new)
    #x_new=np.array(range(0,50.5,0.5))
    z_new=[]
    for i in range(Nt):
        z_cur=Z_old[i,:]
        z_values=values_interpolate(x_new,x_old,z_cur)
        z_new.append(z_values)
    Z_new=np.array(z_new)
    return Z_new

def new_values_radial(Z_old):
    #Nt = 15
    x_old = linspace(pi, pi/2, 17)
    #x_old=np.array([0,10,20,30,40,50])
    x_new=linspace(pi, pi/2, Nt_new)
    #x_new=np.array(range(0,50.5,0.5))
    z_new=[]
    Z_old = np.transpose(Z_old)
    for i in range(Nr_new):
        z_cur=Z_old[i,:]
        z_values=values_interpolate(x_new,x_old,z_cur)
        z_new.append(z_values)
    Z_new=np.array(z_new)
    return Z_new